package com.cn.lf.wx.dacs.bussiness.author.utils;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.zip.GZIPOutputStream;

public class EncryptUtil {
    //gzip+base64
    public static String encryptStr(String content) throws IOException {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        GZIPOutputStream gzip;
        try {
            gzip = new GZIPOutputStream(out);
            gzip.write(content.getBytes(StandardCharsets.UTF_8));
            gzip.close();
        } catch (IOException e) {
            System.out.println("gzip compress error.");
        }
        return java.util.Base64.getEncoder().encodeToString(out.toByteArray());
    }

    public static void main(String[] args) throws IOException {
        System.out.println(encryptStr("test"));
    }
}
